package com.hcinfos.gsoo.adapter;

import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.hcinfos.gsoo.R;
import com.hcinfos.gsoo.enity.City;
import com.hcinfos.gsoo.enity.ShopInfo;

public class CityAdapter extends BaseAdapter {

	private List<City> list;
	private LayoutInflater mInflater;
	public int index = 0;

	public CityAdapter(Context context, List<City> list) {
		this.list = list;
		mInflater = LayoutInflater.from(context);
	}

	@Override
	public int getCount() {
		return list.size();
	}

	@Override
	public Object getItem(int position) {
		return list.get(position);
	}

	@Override
	public long getItemId(int arg0) {
		return 0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		TypeHolder holder;
		if (convertView == null) {
			convertView = mInflater.inflate(R.layout.city_child, null);
			holder = new TypeHolder();
			holder.nameTv = (TextView) convertView.findViewById(R.id.city_tv);
			convertView.setTag(holder);
		} else {
			holder = (TypeHolder) convertView.getTag();
		}
		holder.nameTv.setText(list.get(position).getName());
		return convertView;
	}

	private final class TypeHolder {
		TextView nameTv;

	}

	public void setDataChange(List<City> list) {
		this.list = list;
		notifyDataSetChanged();
	}

}
